package com.skp.shaphan.ui.windows;

import java.awt.Container;

import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;

import com.skp.lydia.PathSelector;
import com.skp.lydia.layout.CSSLayout;
import com.skp.shaphan.ui.buttons.CompareTablesOkButton;
import com.skp.shaphan.ui.buttons.DialogCancelButton;
import com.skp.shaphan.ui.connectioncontrols.SavedConnectionComboBox;

public class CompareTablesWindow extends JDialog {

	private SavedConnectionComboBox leftConn;
	private SavedConnectionComboBox rightConn;
	private JTextArea recList;
	private PathSelector outputPath;

	public CompareTablesWindow(JFrame parent) {
		super(parent, "Compare");
		setSize(300, 400);
		Container cp = getContentPane();
		cp.setLayout(new CSSLayout());
		
		JLabel label = new JLabel("Left Connection:");
		cp.add(label, "left-margin: 5; top-margin: 5");
		
		leftConn = new SavedConnectionComboBox();
		cp.add(leftConn, "display: inline; left-margin: 5; top-margin: 5");
		
		label = new JLabel("Right Connection:");
		cp.add(label, "left-margin: 5; top-margin: 5");
		rightConn = new SavedConnectionComboBox();
		cp.add(rightConn, "display: inline; left-margin: 5; top-margin: 5");
		
		label = new JLabel("Record List:");
		cp.add(label, "left-margin: 5; top-margin: 5");
		recList = new JTextArea(5, 40);
		JScrollPane scroll = new JScrollPane(recList);
		cp.add(scroll, "display: inline; left-margin: 5; top-margin: 5; height: 100; width: 80%");
		
		label = new JLabel("Output:");
		cp.add(label, "left-margin: 5; top-margin: 5");
		outputPath = new PathSelector();
		cp.add(outputPath, "display: inline; left-margin: 5; top-margin: 5");

		DialogCancelButton cancel = new DialogCancelButton(this);
		cp.add(cancel, "left-margin: 5; top-margin: 5");
		CompareTablesOkButton ok = new CompareTablesOkButton(this);
		cp.add(ok, "display: inline; left-margin: 5; top-margin: 5");
		
		ok.setDefaultCapable(true);
		
		
		leftConn.setSelectedIndex(8);
		rightConn.setSelectedIndex(10);
		recList.setText("PS_INSTALLATION_EX,\nPS_BUS_UNIT_TBL_EX,\nPS_BUS_CAL_HOLIDAY");
		outputPath.setPath("/home/skp/MIS/UM/setup/compare.pdf");
	}
	
	public int getLeftConnId() {
		return leftConn.getSelectedConnection();
	}
	
	public int getRightConnId() {
		return rightConn.getSelectedConnection();
	}
	
	public String getRecords() {
		return recList.getText();
	}
	
	public String getOutputPath() {
		return outputPath.getPath();
	}
}
